package cn.livingCloud.controller.content.validator;

import cn.livingCloud.dto.ReplyRuleFormDto;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by 唐旭 on 2015/12/26.
 */
public abstract class AbstractRuleDtoValidator implements Validator {
    @Override
    public abstract boolean supports(Class<?> aClass);

    @Override
    public abstract void validate(Object o, Errors errors);

    protected void validateRule(ReplyRuleFormDto formDto, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "keyWord", null, "关键字不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "msgType", null, "请选择一种回复类型");
    }
}
